using System;

namespace SharpMud.MudLib.SAMPLE.Net.SessionStates
{
	/// <summary>
	/// Perhaps the shortest lived SessionState. Sends data to the user. Useful for when
	/// ou want to send the user something, but you want to but the action on a SessionStateStack
	/// and make it wait its turn.
	/// </summary>
	public class SendData : SessionStateBase
	{
		private string			_MessageToSend;
		private bool			_MessageSent;

		public override string StateID
		{
			get
			{
				return GetStateID();
			}
		}

		protected virtual string GetStateID()
		{
			return "SendData";
		}

		public override void Pulse()
		{
			if(MessageSent==false)
			{
				this.Session.Write(this._MessageToSend);
				_MessageSent = true;
				base.SetInactive();
			}
		}

		public string MessageToSend
		{
			get
			{
				return _MessageToSend;
			}
		}

		public bool MessageSent
		{
			get
			{
				return _MessageSent;
			}
		}

		public SendData(string data)
		{
			this._MessageToSend = data;
			this._MessageSent = false;
		}

		public override void Dispose()
		{
			
		}
	}
}
